#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

void* my_memmove(void* dest, const void* src, size_t size)
{
	void* ret = dest;
	if (dest <= src || (char*)dest >= (char*)src + size)
	{
		while (size--)
		{
			*(char*)dest = *(char*)src;
			dest = (char*)dest + 1;
			src = (char*)src + 1;
		}
	}
	else
	{
		dest = (char*)dest + size - 1;
		src = (char*)src + size - 1;
		while (size--)
		{
			*(char*)dest = *(char*)src;
			dest = (char*)dest - 1;
			src = (char*)src - 1;
		}
	}
	return ret;
}

int main()
{
	int a[10] = { 1,2,3,4,5,6,7,8,9,10 };
	my_memmove(a + 2, a, 20);
	for (int i = 0; i < 10; i++)
		printf("%d ", a[i]);
	return 0;
}